package com.rohoo.news.action;

import java.util.Date;
import java.util.List;

import org.apache.commons.beanutils.BeanUtils;

import com.rohoo.framework.struts.action.BaseAction;
import com.rohoo.news.bo.News;
import com.rohoo.news.dto.NewsDTO;
import com.rohoo.news.service.NewsService;

public class NewsAction extends BaseAction{
	/**
	 * 
	 */
	private static final long serialVersionUID = 8374010318892170644L;

	private NewsService newsService;
	
	private Integer news_id;
	private String title;
	private Date news_time;
	private String writers;
	private String contents;
	private Date create_time;
	private Date update_time;
	private Integer delete_flag;
	private Integer pictures_id;
	private List newsTitleList;

	private String news_time_str;
	private String create_time_str;
	private String update_time_str;
	
	private String deletename;
	
	public String toAdd(){
		return SUCCESS;
	}
	
	public String doAdd() throws Exception{
		News news = new News();
		BeanUtils.copyProperties(news, this);
		newsService.addNews(news);
		return SUCCESS;
	}
	
	public String doQuery() throws Exception {
		NewsDTO dto = new NewsDTO();
		BeanUtils.copyProperties(dto, this);
		this.setDatas(newsService.queryNews(dto));
		return SUCCESS;
	}
	
	public String toNext() throws Exception {
		News news = newsService.getNews(news_id);
		BeanUtils.copyProperties(this, news);       
		return SUCCESS;
	}
	
	public String doEditNews() throws Exception {
		NewsDTO dto = new NewsDTO();
		BeanUtils.copyProperties(dto, this);
		newsService.updateNews(dto);
		return SUCCESS;
	}
	
	public String getNewsList() throws Exception {
		NewsDTO dto = new NewsDTO();
		dto.setRowNum(5);
		newsTitleList = newsService.getNewsTitleList(dto);
		return SUCCESS;
	}

	public NewsService getNewsService() {
		return newsService;
	}

	public void setNewsService(NewsService newsService) {
		this.newsService = newsService;
	}

	public Integer getNews_id() {
		return news_id;
	}

	public void setNews_id(Integer news_id) {
		this.news_id = news_id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Date getNews_time() {
		return news_time;
	}

	public void setNews_time(Date news_time) {
		this.news_time = news_time;
	}

	public String getWriters() {
		return writers;
	}

	public void setWriters(String writers) {
		this.writers = writers;
	}

	public String getContents() {
		return contents;
	}

	public void setContents(String contents) {
		this.contents = contents;
	}

	public Date getCreate_time() {
		return create_time;
	}

	public void setCreate_time(Date create_time) {
		this.create_time = create_time;
	}

	public Date getUpdate_time() {
		return update_time;
	}

	public void setUpdate_time(Date update_time) {
		this.update_time = update_time;
	}

	public Integer getDelete_flag() {
		return delete_flag;
	}

	public void setDelete_flag(Integer delete_flag) {
		this.delete_flag = delete_flag;
	}

	public Integer getPictures_id() {
		return pictures_id;
	}

	public void setPictures_id(Integer pictures_id) {
		this.pictures_id = pictures_id;
	}

	public List getNewsTitleList() {
		return newsTitleList;
	}

	public void setNewsTitleList(List newsTitleList) {
		this.newsTitleList = newsTitleList;
	}

	public String getNews_time_str() {
		return news_time_str;
	}

	public void setNews_time_str(String news_time_str) {
		this.news_time_str = news_time_str;
	}

	public String getCreate_time_str() {
		return create_time_str;
	}

	public void setCreate_time_str(String create_time_str) {
		this.create_time_str = create_time_str;
	}

	public String getUpdate_time_str() {
		return update_time_str;
	}

	public void setUpdate_time_str(String update_time_str) {
		this.update_time_str = update_time_str;
	}
	public String getDeletename() {
		return deletename;
	}
	public void setDeletename(String deletename) {
		this.deletename = deletename;
	}
}
